<template>
  <div>
    <header>
      <comp-header> </comp-header>
    </header>
    <van-tabs v-model="active" scrollspy sticky>
      <van-tab v-for="item in cateList" :key="item.id" :title="item.cate_name">
        <div class="item">
           <van-divider
          :style="{
            color: '#000',
            borderColor: '#000',
            padding: '10px 20px',
          }"
        >
          {{ item.cate_name }}
        </van-divider>
          
          <ul>
            <li v-for="chil in item.children" :key="chil.id">
              <router-link to="/">
                <img :src="chil.pic" alt="" />
                <p>{{ chil.cate_name }}</p>
              </router-link>
            </li>
          </ul>
        </div>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import compHeader from "../components/compHeader.vue";
import { get, post } from "../../utils/util";
export default {
  name: "pageHome",
  data() {
    return {
      cateList: null,
      active:''
    };
  },
  components: {
    "comp-header": compHeader,
  },
  created() {
    get("/category").then((res) => {
      console.log(res);
      this.cateList = res.data;
    });
   
  },
};
</script>

<style lang="scss" scoped>
.item {
  h4 {
    font-size: 14px;
    text-align: center;
    height: 70px;
    line-height: 70px;
    position: relative;
  }
  ul {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    li {
      flex-basis: 33.33%;
      text-align: center;
      padding: 10px 0 ;
      a {
        img {
          width: 70px;
          height: 70px;
        }
        p {
          font-size: 14px;
        }
      }
    }
  }
}
</style>